package com.zntg.api.renGouShu;
import com.zntg.api.renGouShu.bo.TblobstorageBo;
import com.zntg.api.renGouShu.result.ResultModel;
import com.zntg.service.TblobstorageService;
import com.zntg.contants.ShuangLuApiContants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @Description: 报表平台手动生成申购书的功能
 * @Description: 份额确认生成书
 * 先生成确认书，如果成功，返回文件大小
 * @Author: zhengyunfei
 * @Date: 2018/6/15
 * @time:11:26
 */
@Api(value = ShuangLuApiContants.RENGOUSHU_NAMESPACE,tags =  ShuangLuApiContants.RENGOUSHU_NAMESPACE )
@RestController
@RequestMapping("/api/crm/tblobstorage")
public class TCustBuyinApiController {
    @Autowired
    private TblobstorageService tblobstorageService;
    @PostMapping("/get")
    @ApiOperation(value = "获取信息",notes = "获取信息",position = 1,response = Object.class)
    @ResponseBody
    public Object post(){
        ResultModel resultModel=new ResultModel();
        //查询附件需要
        int xh=tblobstorageService.getTblobStorageSeq();
        try{
            resultModel.setData(xh);

        }catch (Exception e){

        }
        return resultModel;
    }
    /**
    * @Description: 获取信息
    * @Author: zhengyunfei
    * @Date: 2018/12/13
    * @time:14:18
    */
    @GetMapping("/get")
    @ApiOperation(value = "获取信息",notes = "获取信息",position = 1,response = Object.class)
    @ResponseBody
    public Object get(){
        ResultModel resultModel=new ResultModel();
        //查询附件需要
        int xh=tblobstorageService.getTblobStorageSeq();
        try{
            resultModel.setData(xh);

        }catch (Exception e){

        }
        return resultModel;
    }
    /**
    * @Description: 写入日志信息
    * @Author: zhengyunfei
    * @Date: 2018/12/13
    * @time:14:18
    */

    @PostMapping(value = "/add",produces = "application/json;charset=UTF-8")
    @ApiOperation(value = "插入crm附件信息",notes = "插入crm附件信息",position = 1,response = Object.class)
    @ResponseBody
    public Object insert(TblobstorageBo tblobstorageBo){
        ResultModel resultModel=new ResultModel();
        //查询附件需要
        try{
            System.out.println("保存附件开始。。。。。。。。。。。。。。。。。"+tblobstorageBo.getLStorageid());
            tblobstorageService.add(tblobstorageBo);
            System.out.println("保存附件成功。。。。。。。。。。。。。。。。。");
            resultModel.setCode(0);
            resultModel.setMessage("成功");
        }catch (Exception e){
            e.printStackTrace();
            resultModel.setCode(-1);
            resultModel.setMessage("失败");

        }
        return resultModel;
    }
}
